<?php session_start();?>
<!DOCTYPE html>
<html>
	<head>
		<title>Iframe</title>
		<meta http-equiv="Content-Type" content="text/html; charset=Windows-1251" />
		
		<!-- Stylesheet -->
		<link rel="stylesheet" type="text/css" href="css/styles.css" />
	</head>
	<body>
<?php
if( (!isset($_GET['id'])) || (!(isset($_SESSION['vehicle'][$_GET['id']]))) )
{
?>
	<div class="no_result"><?php echo mb_convert_encoding('Няма намерени резултати','Windows-1251','UTF-8'); ?></div>
<?php
	return 0;
}
$languageId = 32;
$result = $_SESSION['vehicle'][$_GET['id']];

foreach($_SESSION['fuel_type'] as $key => $data)
{
	if(is_numeric($key))
		$fuel_type[$data->id] = $data->name;
	else
		$fuel_type[$_SESSION['fuel_type']->id] = $_SESSION['fuel_type']->name;
}

if(!isset($client))
{
	$options = array('languageId'=>$languageId,'trace' => 1,'login' => 'autohit2','password' => 'bont39er','encoding' => 'ISO-8859-1','trace' => true,'exceptions' => true);
	$client = new SoapClient('http://autohit.web-catalogue.eu/main/service/vehicle.wsdl',$options);
}

$parameters_models = array(
	'languageId' => $languageId,
	'vehicleType' => 1,
	'vehicleTypeId' => $result->id
);

$result_details = $client->vehicleDetails($parameters_models);
if(substr($result->manufacturedTo,0,4))
	$checkVehicleYear = substr($result_details->details->manufacturedFrom,0,4).'-'.substr($result_details->details->manufacturedTo,0,4);
else
	$checkVehicleYear = substr($result_details->details->manufacturedFrom,0,4);
?>
		<table border="0" class="table_iframe" width="100%" cellspacing="6" cellpadding="0">
			<tr><th colspan="2" class="header"><?php echo mb_convert_encoding('Общ','Windows-1251','UTF-8'); ?></th></tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Тип','Windows-1251','UTF-8'); ?></td>
				<td><?php echo $result_details->details->type?></td>
			</tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Година на произв. [от-до]','Windows-1251','UTF-8'); ?></td>
				<td><?php echo $checkVehicleYear?></td>
			</tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Вид на купе','Windows-1251','UTF-8'); ?></td>
				<td><?php echo $result->bodyTypeName?></td>
			</tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Литри','Windows-1251','UTF-8'); ?></td>
				<td><?php echo $result_details->details->litre?></td>
			</tr>

			<tr><th colspan="2" class="header"><?php echo mb_convert_encoding('Технически данни','Windows-1251','UTF-8'); ?></th></tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Мощност [КВ]','Windows-1251','UTF-8'); ?></td>
				<td><?php echo $result_details->details->kw?></td>
			</tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Мощност [КС]','Windows-1251','UTF-8'); ?></td>
				<td><?php echo $result_details->details->hp?></td>
			</tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Работен обем [куб.см.]','Windows-1251','UTF-8'); ?></td>
				<td><?php echo $result_details->details->ccm?></td>
			</tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Цилиндри','Windows-1251','UTF-8'); ?></td>
				<td><?php echo $result_details->details->cylinderNumber?></td>
			</tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Клапани на цилиндър','Windows-1251','UTF-8'); ?></td>
				<td><?php echo $result_details->details->valvePerCylinder?></td>
			</tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Вид гориво','Windows-1251','UTF-8'); ?></td>
				<td><?php echo $result_details->details->fuelType?></td>
			</tr>
			<tr>
				<td class="title"><?php echo mb_convert_encoding('Двигател','Windows-1251','UTF-8'); ?></td>
				<td>
				<?php
				if(isset($result_details->details->engineCodes))
				{
					if(is_array($result_details->details->engineCodes))
						echo implode(', ', $result_details->details->engineCodes);
					else
						echo $result_details->details->engineCodes;
				}
				?>
				</td>
			</tr>
		</table>
	</body>
</html>
